package com.gzhu.knowledgeAdmin.common.enums;


import org.springframework.util.StringUtils;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 搜索类型枚举
 */
public enum ParamTypeEnum {

    TEMPLATE_TYPE("templateType"),
    ANSWER_TYPE("answerType"),
    RECORDER("recorder"),
    VARIABLE("variable"),
    DenoiseLevel("jzdj"),
    RecognitionMode("sbms"),
    CATEGORY("category"),
    INTENTION_JUDGE_CONDITION("intentionJudgeCondition");

    private final String value;

    ParamTypeEnum(String value) {
        this.value = value;
    }

    /**
     * 获取值列表
     *
     * @return
     */
    public static List<String> getValues() {
        return Arrays.stream(values()).map(item -> item.value).collect(Collectors.toList());
    }

    /**
     * 根据 value 获取枚举
     *
     * @param value
     * @return
     */
    public static ParamTypeEnum getEnumByValue(String value) {
        if (StringUtils.isEmpty(value)) {
            return null;
        }
        for (ParamTypeEnum anEnum : ParamTypeEnum.values()) {
            if (anEnum.value.equals(value)) {
                return anEnum;
            }
        }
        return null;
    }

    public String getValue() {
        return value;
    }

}
